package chessGame.piece;

import chessGame.Board;
import chessGame.annotation.PieceInfo;
import chessGame.move.MoveStrategy;
import chessGame.move.RookMoveStrategy;
import chessGame.utils.MoveUtils;
import chessLib.Position;

import java.util.Collection;
import java.util.Set;

/**
 * @BelongsProject: chessGame
 * @BelongsPackage: chessGame.piece
 * @CreateTime: 2025-10-08  21:13
 * @Description: 车棋子
 * @Version: 1.0
 */
@PieceInfo(value = "Rook")
public class Rook extends Piece{

    private final MoveStrategy moveStrategy;


    public Rook(String pieceName) {
        super(pieceName);
        this.moveStrategy = new RookMoveStrategy();
    }

    @Override
    public Set<Position> getValidMoves(Position currentPosition, Board board) {
        Collection<Position> positions = moveStrategy.validMovesFor(currentPosition);
        return MoveUtils.deduplication(positions, board);
    }

    @Override
    public String getName() {
        return "Rook";
    }
}
